#ifndef _OCPP_RequestHandler_H__
#define _OCPP_RequestHandler_H__

#include "Request.h"
#include "Response.h"

namespace OCPP
{
	class _MainExport RequestHandler
	{
	public:
		RequestHandler() {}
		virtual ~RequestHandler() {}

		/** Return whether this handler can process a given request.
		@remarks
		Defaults to true, but if you wish to add several handlers each of
		which deal with different types of request, you can override
		this method.
		*/
		virtual bool canHandleRequest(const Request* req, const WorkQueue* srcQ)
		{
			(void)srcQ; return !req->getAborted();
		}

		/** The handler method every subclass must implement.
		If a failure is encountered, return a Response with a failure
		result rather than raise an exception.
		@param req The Request structure, which is effectively owned by the
		handler during this call. It must be attached to the returned
		Response regardless of success or failure.
		@param srcQ The work queue that this request originated from
		@return Pointer to a Response object - the caller is responsible
		for deleting the object.
		*/
		virtual Response* handleRequest(const Request* req, const WorkQueue* srcQ) = 0;
	};
}

#endif
